package Dao.Impl;

import Dao.AdminDao;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import pojo.Admin;
import utils.DruidJbdcUtils;

import java.sql.SQLException;

/**
 * @author zhangyu
 * @date 2021/11/17    20:54
 */
public class AdminDaoImpl implements AdminDao {
    @Override
    public Admin selectAdminByName(String name) throws SQLException {
        QueryRunner qr = new QueryRunner(DruidJbdcUtils.getDataSource());
        String sql = "select * from admin where username = ?";
        Admin admin = qr.query(sql, new BeanHandler<Admin>(Admin.class), name);
        return admin;
    }
}
